using B.S.BasicData.Api.Write.Application.Command.Customer;
using B.S.BasicData.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace B.S.BasicData.Api.Write.Controllers
{
    /// <summary>
    /// 客户管理控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize]
    public class CustomerController : ControllerBase
    {
        private readonly IMediator mediator;

        public CustomerController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 新增客户
        /// </summary>
        /// <param name="request">客户信息</param>
        /// <returns>新增客户的ID</returns>
        [HttpPost]
        public Task<ApiResult<int>> Create([FromBody] CreateCustomerCommand request)
        {
            return mediator.Send(request);
        }
    }
}